<?php

/*************************************************/
/*     __            __    ____                  */
/*    / / ___  ____ / /_  / __/__  ____ __ ___   */
/*   / /_/ -_|/ __//  _/ _\ \/ ° // __// // _ \  */
/*  /___/\__//_/  /_/   /___/\__//_/  /_//_//_/  */
/*                                               */
/*************************************************/

/**
 * Classe représentant l'objet Actu
 * @author Molinier Danik
 * @package modele
 */
class Actu extends ModelBase{


	/**
	 * Constructeur
	 */
	function Actu(){
		$this->id = null;
		$this->type = array('titre' => 'string',
							'date' => 'int',
							'text' => 'string');
		
		
		$this->att = array('titre' => null,
							'date' => 0,
							'text' => null);
		
		$this->tname = "actu";
		$this->mname = __CLASS__;
	}

	function get10(){
		$db = Connexion::getConnexion();
		
		//$res = mysql_query("Select * from ".$this->tname." LIMIT 10;");

		$res = $db->query("Select * from ".$this->tname." ORDER BY date desc LIMIT 10;");
		
		$all = null;
		
		if(!$res){
			echo "erreur : ".mysql_errno()." : ".mysql_error();
		}else if($res->num_rows != 0){
			while($rows = $res->fetch_assoc()){
				$r = new $this->mname();
				$r->id = $rows['id'];
				foreach ($this->att as $attr => $t) {
					$r->setAttr($attr, $rows[$attr]);
				}
				$all[] = $r;
			}
		}
		return $all;
	}
}
?>